<table class="form_table">
	<tr><td>选择系：</td><td><select id="updateCollegeSelect" class="select"></select></td></tr>
	<tr><td>系名称：</td><td><input class="txtInput" id="updateCollegeNameInput" ></td></tr>
	<tr><td></td><td><input type="button" class="btnSubmit" id="updateCollegeButton" value="提交"></td></tr>
</table>

<script>
$(function(){

	$('#updateCollegeSelect').change(function(){
		$('#updateCollegeNameInput').val($('#updateCollegeSelect :selected').html());
	});

	updateCollegeSelect();

	function updateCollegeSelect(collegeId) {
		$.ajax({
			url:'uni/colleges',
			success:function(scholarshipTypes) {
				var options = $.map(scholarshipTypes,function(row) {
					return '<option value="' + row.lqyxsm + '">' + row.lqyxsmc + '</option>';
				}).join('');
				$('#updateCollegeSelect').html(options);
				if(collegeId) $('#updateCollegeSelect').val(collegeId);
				$('#updateCollegeSelect').change();
			}
		});
	}

	$('#updateCollegeButton').click(function(){
		var collegeId = $('#updateCollegeSelect').val();
		if(!$.trim($('#updateCollegeNameInput').val())) {$.messager.alert('提示','系名称不能为空！');return;}
		$.ajax({
			url:'uni/collegeAct',
			data:{action:'edit',collegeId:collegeId,collegeName:$('#updateCollegeNameInput').val()},
			success:function(result) {
				if(result.errorInfo != 'none') {$.messager.alert('提示',result.errorInfo);return;}
				$.messager.alert('提示','系信息更新完成！');
				updateCollegeSelect(collegeId);
			}
		});
		
	});
});
</script>